import type { User } from '@/types/user.d'
import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useUserStore = defineStore(
  'user',
  () => {
    // 用户信息
    const userInfo = ref<User>()
    // 修改用户信息
    const setUser = (u: User) => {
      userInfo.value = u
    }
    // 删除用户信息
    const delUser = () => {
      userInfo.value = undefined
    }
    return {
      userInfo,
      setUser,
      delUser
    }
  },
  { persist: true }
)
